import time
import random
f = open('m1_sorted.txt','r')
f1 = open('m2_reverse.txt','r')
f2 = open('m3_shuffle.txt','r')
name0 = f.name.split(".")[0]
name1 = f1.name.split(".")[0]
name2 = f2.name.split(".")[0]

f = f.read().split()
f = [int (i) for i in f]
f1 = f1.read().split()
f1 = [int (i) for i in f1]
f2 = f2.read().split()
f2 = [int (i) for i in f2]
def sortirovka(a):
    for j in range(1,len(a)):
        for i in range(len(a)-j):
            if a[i]>a[i + 1]:
                a[i],a[i + 1]=a[i + 1],a[i]
    return a
st = time.time()
sortirovka(f)
et = time.time()
st1 = time.time()
sortirovka(f1)
et1 = time.time()
st2 = time.time()
sortirovka(f2)
et2 = time.time()
print(name0,round((et-st)*1000),"milliseconds")
print(name1,round((et1-st1)*1000),"milliseconds")
print(name2,round((et2-st2)*1000),"milliseconds")